<template>
	<view class="">
		<view style="margin-bottom: 15px;">
			<uni-card isFull="false" @click="tologin()">
				<view class="user_photo">
					<u-avatar :src="src" style="margin-right: 20px;"></u-avatar>
				</view>
				<view class="user_photo">{{stuname}}</view>
			</uni-card>
		</view>
		<view class="">
			<u-cell-group>
				<u-cell-item icon="list-dot" title="个人资料" @click="toinfo" hover-class="cell-hover-class"></u-cell-item>
				<u-cell-item icon="bookmark" title="我的作业" @click="tomywork" hover-class="cell-hover-class"></u-cell-item>
				<u-cell-item icon="setting-fill" title="设置" @click="toset" hover-class="cell-hover-class"></u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				stuid: "",
				stuname: "",
				src: ""
			}
		},
		onShow() {
			this.stuid = uni.getStorageSync("stuid");
			this.stuname = uni.getStorageSync("stuname");
		},
		methods: {
			toinfo() {
				if (!this.stuid) {
					uni.navigateTo({
						url: "../xiaocong-login/login/login"
					})
				}
				else {
					uni.navigateTo({
						url: "info"
					})
				}
				console.log(this.stuid);
				console.log("成功");
			},
			tomywork() {

				if (!this.stuid) {
					uni.navigateTo({
						url: "../xiaocong-login/login/login"
					})
				}
				else {
					uni.navigateTo({
						url: "../homework/homework"
					})
				}

				uni.navigateTo({
					url: "../homework/homework"
				})

			},
			toset() {
				if (!this.stuid) {
					uni.navigateTo({
						url: "../xiaocong-login/login/login"
					})
				}
				else {
					uni.navigateTo({
						url: "setup"
					})
				}
			},
			tologin() {
				if (!this.stuid) {
					uni.navigateTo({
						url: "../xiaocong-login/login/login"
					})
				}
				else {
					uni.navigateTo({
						url: "info"
					})
				}
			}
		}
	}
</script>

<style>
	.user_photo {
		float: left;
	}
	
	/* App.vue */
	.cell-hover-class {
		background-color: rgb(235, 237, 238);
	}
	
	/* 或者单是设置透明度 */
	.cell-hover-class {
		opacity: 0.5;
	}
</style>
